package gold.contest;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC6101 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public boolean checkXMatrix(int[][] grid) {
            int n = grid.length;
            for (int i = 0; i < n; i++) {
                if (grid[i][i] == 0) return false;
                if (grid[i][n - i - 1] == 0) return false;
            }

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (i == j || j == n - i - 1) continue;
                    if (grid[i][j] != 0) return false;
                }
            }

            return true;
        }
    }

    public void run() {
        System.out.println(new Solution().checkXMatrix(InputUtil.toDoubleIntegerArray("[[2,0,0,1],[0,3,1,0],[0,5,2,0],[4,0,0,2]]")));
        System.out.println(new Solution().checkXMatrix(InputUtil.toDoubleIntegerArray("[[5,7,0],[0,3,1],[0,5,0]]")));
    }

    public static void main(String[] args) throws Exception {
        LC6101 an = new LC6101();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
